/*
 * Copyright (c) 2021 chwxu@outlook.com
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this list of
 *    conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
 *    of conditions and the following disclaimer in the documentation and/or other materials
 *    provided with the distribution.
 *
 * 3. Neither the name of the copyright holder nor the names of its contributors may be used
 *    to endorse or promote products derived from this software without specific prior written
 *    permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
import { BasicColumn } from '/@/components/Table/src/types/table';

export function getCommitsColumns(): BasicColumn[] {
  return [
    {
      title: 'Project', dataIndex: 'project', key: 'project', width: 125, fixed: 'left',
      slots: {
        filterDropdown: 'filterDropdown',
        filterIcon: 'filterIcon',
        customRender: 'customRender',
      },
      onFilter: (value, record) =>
        record.project.toString().toLowerCase().includes(value.toLowerCase()),
      onFilterDropdownVisibleChange: visible => {
        if (visible) {
          setTimeout(() => {
            console.log(searchInput.value);
            searchInput.value.focus();
          }, 100);
        }
      },
    },
    {
      title: 'Repo', dataIndex: 'repo', key: 'repo', width: 150,
      slots: {
        filterDropdown: 'filterDropdown',
        filterIcon: 'filterIcon',
        customRender: 'customRender',
      },
      onFilter: (value, record) =>
        record.repo.toString().toLowerCase().includes(value.toLowerCase()),
      onFilterDropdownVisibleChange: visible => {
        if (visible) {
          setTimeout(() => {
            console.log(searchInput.value);
            searchInput.value.focus();
          }, 100);
        }
      },
    },
    { title: 'PR#', dataIndex: 'pr_number', key: 'pr_number', width: 75 },
    { title: 'ClosedAt', dataIndex: 'closed_at', key: 'closed_at', width: 200 },
    { title: 'SHA', dataIndex: 'sha', key: 'sha', width: 195 },
    { title: 'AuthorID', dataIndex: 'author_id', key: 'author_id', width: 100 },
    { title: 'AuthorName', dataIndex: 'author_name', key: 'author_name', width: 150 },
    {
      title: 'AuthorEmail', dataIndex: 'author_email', key: 'author_email', width: 250, slots: {
        filterDropdown: 'filterDropdown',
        filterIcon: 'filterIcon',
        customRender: 'customRender',
      },
      onFilter: (value, record) =>
        record.author_email.toString().toLowerCase().includes(value.toLowerCase()),
      onFilterDropdownVisibleChange: visible => {
        if (visible) {
          setTimeout(() => {
            console.log(searchInput.value);
            searchInput.value.focus();
          }, 100);
        }
      },
    },
    { title: '+', dataIndex: 'addition', key: 'add', width: 75 },
    { title: '-', dataIndex: 'deletion', key: 'del', width: 75 },
  ];
}
